/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package testes;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

/**
 *
 * @author PRTurbo
 */
public class FileWriterDemo {

    public static void main(String args[]) {
//        try {
//            PrintWriter output = new PrintWriter(new FileWriter("teste.txt", true));
//            output.append("Teste\r\n");
//            output.close();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }


        String palavra = null;
        try {
            FileReader input = new FileReader("comentario.txt");
            PrintWriter output = new PrintWriter(new FileWriter("tst.txt", true));
            BufferedReader br = new BufferedReader(input);
//            BufferedWriter bw = new BufferedWriter(output);
            String linha;
            while ((linha = br.readLine()) != null) {
                if (linha.contains("COMMENT")) {
                    output.append(linha + "\r\n");
                }
            }
            output.close();
            br.close();
            input.close();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
